Skip to content

fix: Asymmetric Payout Arithmetic and Consistency Refactor#346

Merged
gboigwe merged 1 commit intoThinkLikeAFounder:mainfrom
Dopezapha:fix/payout-arithmetic-consistency-307
Mar 28, 2026
Merged

fix: Asymmetric Payout Arithmetic and Consistency Refactor#346
gboigwe merged 1 commit intoThinkLikeAFounder:mainfrom
Dopezapha:fix/payout-arithmetic-consistency-307

Conversation

@Dopezapha
Copy link
Copy Markdown
Contributor

Closes #307

Description

This PR resolves a critical inconsistency in the payout-automation contract where total_paid calculations were unchecked while pending_amount used saturating arithmetic (#307). This asymmetry previously masked accounting bugs and could lead to silent data corruption or illogical contract states.

Key Changes

  • Consistently Checked Arithmetic: All financial state transitions for PublisherEarnings now use checked_add and checked_sub with explicit error handling.

  • Improved Diagnostics: Updated the failure messages in execute_payout to correctly identify underflows in pending_earnings, facilitating better troubleshooting of upstream registry errors.

  • Entry-Point Hardening: Added non-zero validation and minimum payout enforcement (reading from contract instance storage) to schedule_payout to prevent logic inversions.

  • Ledger Counter Safety: Upgraded the payout_id sequence to a checked counter.

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 28, 2026

@Dopezapha Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@gboigwe gboigwe merged commit f763b4d into ThinkLikeAFounder:main Mar 28, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] payout-automation: asymmetric overflow handling — total_paid unchecked vs pending_amount saturating

2 participants